<ol class="breadcrumb">
    <li><a href="#">点单服务</a></li>
    <li><a href="/cafe/goods/list">商品管理</a></li>
    <li>新增商品</li>
</ol>

<div class="panel panel-default">
    <div class="panel-heading">
        <span class="glyphicon glyphicon-pencil"></span>
        <span class="panel-title">请填写商品信息</span>
    </div>
    <div class="panel-body">
        <form action="/cafe/goods/create" method="post" enctype="multipart/form-data" class="form-horizontal">
            <% if(session.permissionMap[4010]){ %>
            <div class="form-group">
                <label class="control-label col-xs-2">商品所属</label>

                <div class="col-xs-9">
                    <select name="suid" class="form-control">
                        <option value="">请选择商品所属用户</option>
                        <% data.users.forEach(function(el, index, list){ %>
                        <option value="<%= el._id %>"><%= el.user %></option>
                        <% }); %>
                    </select>
                </div>
            </div>
            <script type="text/javascript">
                $(function () {
                    $('[name="suid"]').change(function () {
                        $('[name="category"] option[value!=""]').css('display', 'none');
                        $('[data-user-id="' + $(this).val() + '"]').css('display', '');
                    });
                });
            </script>
            <% } %>
            <div class="form-group">
                <label class="control-label col-xs-2">商品类目</label>

                <div class="col-xs-9">
                    <select name="category" class="form-control">
                        <option value="">请选择商品类目</option>
                        <% data.categories.forEach(function(el, index, list){ %>
                        <option value="<%= el.value %>"
                                data-user-id='<%= el.suid %>' <%- session.permissionMap[4010] ? 'style="display: none;"' : '' %>><%= el.name %></option>
                        <% }); %>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-xs-2">商品名称</label>

                <div class="col-xs-9">
                    <input type="text" name="name" class="form-control" placeholder="请输入商品名称">
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-xs-2">商品价格</label>

                <div class="col-xs-9">
                    <div class="input-group">
                        <span class="input-group-addon">￥</span>
                        <input type="text" name="price" class="form-control" placeholder="请输入商品价格（单位：元）">
                        <span class="input-group-addon">.00</span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-xs-2">商品备注</label>

                <div class="col-xs-9">
                    <input type="text" name="note" class="form-control" placeholder="请输入商品备注">
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-xs-2">商品图片</label>

                <div class="col-xs-9">
                    <input type="file" name="pic" class="form-control" placeholder="请输入商品图片">
                </div>
            </div>
            <div class="form-group">
                <div class="col-xs-2 col-xs-offset-2">
                    <input type="submit" class="form-control btn btn-success">
                </div>
            </div>
        </form>
    </div>
</div>